import random
from card import *
class Deck():
    ''''shuffle' (bool) : shuffle deck.'''

    suits =     ('spade','heart','club','diamond')
    values =     ('A','2','3','4','5','6','7','8','9','10','J','Q','K')
    
    def __init__(self, populate):
        '''Initializes proper deck of 108 Uno Cards.'''
        self.deck = []
        if populate:
            self.populate(True)
            
    def __getitem__(self, index):
        return self.deck[index]
            
    def populate(self, shuffle=True):
        for suit in self.suits:
            for value in self.values:
                self.deck.append(Card(suit, value))
        self.deck.append(Card('JACK', 'JACK'))
        self.deck.append(Card('jack', 'jack'))
        if shuffle:
            self.shuffle()

    def __iter__(self):
        return iter(self.deck)

    def __len__(self):
        return len(self.deck)

    def draw(self):
        return self.deck.pop()
    
    def place(self, card):
        return self.deck.append(card)
    
    def insert(self, card):
        self.deck.insert(0, card)

    def shuffle(self):
        random.shuffle(self.deck)

if __name__ == "__main__":
    dk = Deck(True)
    while len(dk.deck)>0:
        print(dk.deck.pop())